/*
    This file is part of the Time-of-Flight Tracer program. It is not part of
    the original PBRT source distribution. See the included license file for
    more information.

    Copyright(c) 2014 Microsoft Corporation

    Author: Phil Pitts
*/

#if defined(_MSC_VER)
#pragma once
#endif

#ifndef PBRT_INTEGRATORS_TOFDIRECT_H
#define PBRT_INTEGRATORS_TOFDIRECT_H

#include "pbrt.h"
#include "integrator.h"
#include "integrators/directlighting.h"


class ToFDirectIntegrator : public SurfaceIntegrator {
public:
	ToFDirectIntegrator(float lambdaMin = 400, float lambdaMax = 1000);
	~ToFDirectIntegrator();

	void Preprocess(const Scene *scene, const Camera *camera, 
		const Renderer *renderer);
	void RequestSamples(Sampler *sampler, Sample *sample, const Scene *scene);

	IntegrationResult Li(const Scene *scene, const Renderer *renderer,
        const RayDifferential &ray, const Intersection &isect,
        const Sample *sample, RNG &rng, MemoryArena &arena) const;

private:
	float lambdaMin, lambdaMax;
	Distribution1D *lightDistribution;
	LightSampleOffsets *lightSampleOffset;
	BSDFSampleOffsets *bsdfSampleOffset;
	int lightNumOffset;
};


ToFDirectIntegrator *CreateToFDirectSurfaceIntegrator(const ParamSet &params);

#endif // PBRT_INTEGRATORS_TOFDIRECT_H
